<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box {
        position: absolute;
        width: 200px;
        height: 200px;
        background-color: pink;
        margin: 200px;
    }
    .box1 {
 /* 内部⼤⼩ */
 width: 0px;
 height: 0px;
 /* 边框⼤⼩ 只设置两条边*/
 border-top: #4285f4 solid;
 border-right: transparent solid;
 border-width: 85px;
 /* 其他设置 */
 margin: 50px;
}
</style>

<body>
    <div class="box">

    </div>
    <div class="box1">
        
    </div>
</body>
<script>
    const box = document.querySelector('.box')
            box.onmousedown = (e) => {
                // 鼠标在盒子内的坐标
                let mouseX = e.clientX - box.offsetLeft
                let mouseY = e.clientY - box.offsetTop
                document.onmousemove = (cur) => {
                    let left = cur.clientX - mouseX
                    let top = cur.clientY - mouseY
                    box.style.left = left - 200 + 'px'
                    box.style.top = top -200 + 'px'
                }
                document.onmouseup = () => {
                    document.onmousemove = null;
                    document.onmouseup = null;
                }
            }
</script>

</html>